package com.ae.shield.common.capability.Itemhandler;

import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class ProItemStackHandler implements ICapabilityProvider {
    private final LazyOptional<IItemHandler> lazyOptional;
    protected final int size;
    protected final ItemStack stack;

    public ProItemStackHandler(int sizeIn, ItemStack stackIn){
        size = sizeIn;
        stack = stackIn;
        lazyOptional = LazyOptional.of(() -> new ModItemStackHandler(sizeIn, stackIn));
    }

    @Nonnull
    @Override
    public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.orEmpty(cap, lazyOptional);
    }

}
